﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UpdatorYaml
{
    public class YamlDecode
    {
        public YamlDecode()
        {
            
        }
        public string GetToolName(string content)
        {
            int location = content.IndexOf(@"name:");
            int location1 = content.IndexOf(@"version:");
            if (location >= 0 && location1 >= 0)
            {
                location = location + ("name:").Length + 1;
                int length = location1 - location;
                return content.Substring(location, length);
            }
            else
            {
                return string.Empty;
            }
        }
        public int GetVersionCode(string content)
        {
            int location = content.IndexOf(@"versionCode:");
            if (location >= 0)
            {
                location = location + ("versionCode:").Length + 2;
                string version = content.Substring(location, 3);
                return int.Parse(version);
            }
            else
            {
                return -1;
            }
        }
    }
}
